#Property of Jack Stephenson (bancast on github)
#sorry for bad documentation (I haven't slept for the past 36-ish hours)

class Player:
    def __init__(self):
        #setup
        self.last_food = 300
        self.previous_reps = []

    def hunt_choices(self, round_number, current_food, current_reputation, m,  player_reputations):
        choices = []

        #Do Stats stuff
        player_count = len(player_reputations)
        rep_mean = sum(player_reputations)/player_count
        below_curve = len([x for x in player_reputations if x <= rep_mean])
        above_curve = player_count - below_curve

        #get borders on current_reputation used later
        above_below = current_reputation / 10
        
        #get the moving average score
        if round_number > 1:
            mov = [
                sum(self.previous_reps[-5:])/5,
                sum(self.previous_reps[-3:])/3,
                self.previous_reps[-1]
            ]

            entire_trust = mov[-1]-(mov[-3]-mov[-2])#bad naming scheme
        else:
            entire_trust = 1.0

        #If low on food preserve
        if current_food > 200:
            risk = 1.0
        else:
            risk = 2.0

        #Iterate through reputations to make choices
        for x in player_reputations:
            #Get a comparative-based reputation score
            if x == 1.0:
                trust = 0.9
            elif current_reputation+above_below <= x:
                trust = 0.8
            elif current_reputation <= x:
                trust = 0.6
            elif current_reputation-above_below <= x:
                trust = 0.4
            else:
                trust = 0.2

            #bad choices mech
            if (entire_trust + trust) / risk > 0.5:
                choices.append('h')
            else:
                choices.append('s')

        #preserve some details
        self.last_food = current_food
        self.previous_reps.append(rep_mean)
        return choices

    def hunt_outcomes(self, food_earnings):
        #Uneeded apparently
        pass

    def round_end(self, award, m, number_hunters):
        #Uneeded apparently
        pass
